const ejs = require('ejs');
module.exports = async(ctx,renderer,template) => {
   ctx.headers['Content-Type'] = 'text/heml';

   const context = { url:ctx.path } //获取server-entry.js中的context

   try{
      const appString = await renderer.renderToString(context)
      const html = ejs.render(template,{
        appString,
        style:context.renderStyles(),
        scripts:context.renderScripts()
      })
      ctx.body = html;
   }catch(err){
      console.log('render error',err)
      throw err
   }
}